<template>
	<view>
		<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
			<!-- :down="downOption" :up="upOption" -->

			<uni-list>

				<view class="item" v-for="(item, index) in listdata" :key="index">

					<text class="title">
						交车信息
					</text>

					<u-line color="#efefef" :customStyle="{'margin-bottom': '30rpx','display': 'block',}"></u-line>

					<view class="text-line">
						<text class="text-name">交车时间:</text>
						<text class="text-value">{{item.timeDelivery|filterNull}}</text>
					</view>

					<view class="text-line">
						<text class="text-name">交车工作人员:</text>
						<text class="text-value">{{item.deliveryOperationName|filterNull}}</text>
					</view>

					<view class="text-line">
						<text class="text-name">备注:</text>
						<text class="text-value">{{item.deliveryDesc|filterNull}}</text>
					</view>

					<view class="text-line">
						<text class="text-name">交车当前里程数/km:</text>
						<text class="text-value">{{item.deliveryMileage|filterNull}}</text>
					</view>

					<view class="text-line">
						<text class="text-name">下次保养公里数/km:</text>
						<text class="text-value">{{item.mileageNextMaintenance|filterNull}}</text>
					</view>

					<view class="text-line">
						<text class="text-name">下次保养时间:</text>
						<text class="text-value">{{item.mileageNextDate|filterNull}}</text>
					</view>

					<view class="text-line">
						<text class="text-name">交车附件:</text>
						<text v-if="item.accessory == null || item.accessory.length<=0" class="text-value">--</text>
					</view>
					
					<view style="margin: 0 20rpx 20rpx 20rpx;" v-if="item.accessory.length>0">
						<u-album :urls="item.accessory"></u-album>
					</view>

					<!-- <picPdf v-if="item.accessory && item.accessory.length>0" :attachment="item.accessory"></picPdf> -->

				</view>
			</uni-list>

		</mescroll-body>
	</view>
</template>

<script>
	import picPdf from '@/components/pic-pdf.vue';
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";

	export default {
		mixins: [MescrollMixin],
		components: {
			picPdf
		},
		data() {
			return {
				orderCarId: '',
				page: 1,
				listdata: [],
			}
		},
		methods: {
			getData() {
				let that = this

				this.$u.api.getInCarInfor({
						inParameter: this.orderCarId,
						pageNo: this.page,
					}).then(
						res => {
							// if (res.code == 1) {


							if (this.page == 1) {
								this.listdata = [];
							}
							this.listdata = this.listdata.concat(res);
							// }
							
							if (!uni.$u.test.isEmpty(that.listdata)) {
								that.listdata = that.listdata.map(item => {
									if (!uni.$u.test.isEmpty(item.accessory)) {
										item.accessory = item.accessory.map(sitem => {
											return that.baseImgUrl() + sitem
										})
									}
							
									return item
								})
							}
              this.mescroll.endSuccess(res.length);
						}
					)
					.catch(() => {
						this.mescroll.endErr();
					})
			},

			upCallback(page) {
				console.log("触发了上拉加载" + page);

				this.page = page.num;
				this.getData();
			},
		},
		onLoad(op) {
			this.orderCarId = 'null'!=op.orderCarId?op.orderCarId:''
		},
	}
</script>

<style lang="scss" scoped>
	.item {
		display: flex;
		flex-direction: column;
		background-color: white;
		border-radius: 8rpx;
		margin: 10rpx 20rpx;
		padding-bottom: 10rpx;
	}

	.title {
		width: 100%;
		height: 80rpx;
		line-height: 80rpx;
		font-size: 28rpx;
		color: $black33;
		margin-left: 20rpx;
	}
</style>
